import { getRequestConfig } from 'next-intl/server';

// 支持的语言列表
export const locales = ['zh', 'en'] as const;
export type Locale = (typeof locales)[number];

export default getRequestConfig(async ({ requestLocale }) => {
  let locale = await requestLocale;

  // 验证语言是否在支持列表中
  if (!locale || !locales.includes(locale as Locale)) {
    locale = 'zh'; // 默认中文
  }

  return {
    locale,
    messages: (await import(`../messages/${locale}.json`)).default,
  };
});

